<?php
class IndexController extends Zend_Controller_Action
{	
    public function init() {
       
    }
    public function indexAction()
    {
  
        $this->view->title = "Trang chủ | raucuquavn.com";
        $model = new Vina_Model_Products();
        $dataSale = $model->fetchListToArray("is_sale = 1", "id desc", 12);
        
        $model = new Vina_Model_Categories();
        $data = $model->fetchListToArray("1=1", "id desc", 2);
        foreach($data as $key=>$value):
            $modelPro = new Vina_Model_Products();
            $dataRe[$key]['name'] = $value['name'];
            $dataRe[$key]['name_en'] = $value['name_en'];
            $dataRe[$key]['name_china'] = $value['name_china'];
            $dataRe[$key]['id'] = $value['id'];
            $dataRe[$key]['products'] = $modelPro->fetchListToArray("category_id = {$value['id']}", 'id desc', 3);
            
        endforeach;
        $this->view->datare = $dataRe;
        $this->view->data = $dataSale;
    
    }
    public function languageAction(){
        $lang                     =  $this->_request->getParam('lang',false);
        $SS = new Zend_Session_Namespace ('Language');
        $SS->language = $lang;
        $this->_redirect($_SERVER['HTTP_REFERER']);
    }
    	
}
